<?php
namespace common\action;

abstract class Site extends Base{
    
    function execute(){
//        $this->authentication();
        $this->preAction();
        $this->main();
        $this->postAction();
    }

    protected function preAction(){
        $this->_init();
    }

    protected function _init(){}

    protected function regViewPlug(){
        $url = array($this, 'url');
        $this->document->regPlug('url', $url);
        $url_do = array($this, 'urldo');
        $this->document->regPlug('urldo', $url_do);
    }
    
    public function urldo($do = null, $args = []){
        $action = $this->getTask('action');
        if($do){
            $action .= '.' . $do;
        }
        return $this->url($action, $args);
    }

    protected function postAction(){
        if(!$this->document->getTpl()){
            $this->setDefaultTpl();
        }
        $this->regViewPlug();
        $this->assign('action', $this->getTask('action'));
    }
    
}

